package cn.com.guage.guc.thread;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 
 * @author yangdechao
 *使用单线程线程池来实现线程顺序执行
 */
public class FIFOThreadExample2 {
	 public static void foo(String name) {
	        System.out.print(name);
	    }

	    public static void main(String[] args) throws InterruptedException{
	        Thread thread1 = new Thread(() -> foo("A"));
	        Thread thread2 = new Thread(() -> foo("B"));
	        Thread thread3 = new Thread(() -> foo("C"));
	        ExecutorService executor = Executors.newSingleThreadExecutor();
	        executor.submit(thread1);
	        executor.submit(thread2);
	        executor.submit(thread3);
	        executor.shutdown();
	    }

}
